﻿#ifndef URPARSER_H
#define URPARSER_H
#include <QObject>
#include "ur_rtde/rtde.h"
#include <ur_rtde/rtde_control_interface.h>
#include <ur_rtde/rtde_receive_interface.h>
#include <ur_rtde/rtde_io_interface.h>
#include "control_interface.h"

class URParser:public QObject
{
    Q_OBJECT
public:
    URParser();
    static URParser* Instance();
    void connect(QString ip,unsigned int port);
    void disconnect();
    bool isconnected();
    void recive();
    std::vector<double> getActualQ();
    std::vector<double> getActualTcpPos();
    std::vector<double> getActuralTcpForce();
    bool speedl(QString str);
    bool speedl(std::vector<double> speed);
    bool stopspeedL();
    void movej(QString str);
    int getIO_input(int ioID);
    void setSpeedFactor(double fact);

private:
    static URParser* _urparser;
    ur_rtde::RTDE* rtde=nullptr;
    //Control_interface *rtde_control=nullptr;
    ur_rtde::RTDEControlInterface *rtde_control=nullptr;
    ur_rtde::RTDEReceiveInterface *rtde_receive=nullptr;
    ur_rtde::RTDEIOInterface* rtde_io;
    double rtde_frequency=100;
    int rt_receive_priority=90;
    int rt_control_priority=85;
    bool isrun=false;
    double speedfactor=1.0;


};

#endif // URPARSER_H
